/**
 * 
 */
package cn.com.xf.web.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.json.simple.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import cn.com.xf.common.AbstractBaseController;
import cn.com.xf.common.Constants;
import cn.com.xf.common.StringUtil;
import cn.com.xf.domain.TblCheckSchedule;
import cn.com.xf.domain.TblCheckShift;
import cn.com.xf.domain.TblOaAuthPermission;
import cn.com.xf.domain.TblOaAuthRole;
import cn.com.xf.domain.TsUser;
import cn.com.xf.service.CheckShiftService;
import cn.com.xf.service.NoticeService;
import cn.com.xf.service.PushService;
import cn.com.xf.service.SettingService;
import cn.com.xf.service.SmsService;
import cn.com.xf.service.WeeklyService;
import cn.com.xf.utils.encode.EncrypTool;
import cn.com.xf.web.PageModel;
import cn.com.xf.web.XFMappingJacksonJsonView;
import cn.com.xf.web.form.CheckForm;
import cn.com.xf.web.form.LeaveForm;
import cn.com.xf.web.security.UserInfo;

/**
 * @author Administrator
 * 
 */
@Controller
@RequestMapping("/check")
public class CheckController extends AbstractBaseController {
	@Autowired
	private NoticeService noticeService;
	@Autowired
	private PushService pushService;
	@Autowired
	private WeeklyService weeklyService;
	@Autowired
	private SmsService smsService;
	@Autowired
	private CheckShiftService checkShiftService;
	@Autowired
	private SettingService settingService;

	@RequestMapping
	public ModelAndView index(HttpServletRequest request, HttpServletResponse response, CheckForm form)
			throws Exception {
		form.setTab(Constants.TAB_CHECK);
		ModelAndView mv = new ModelAndView("/check/index", Constants.FORM_COMMAND_KEY, form);
		mv.addObject("defaultSiteId", getDefaultSiteId());
		return mv;
	}

	@RequestMapping("/addShift")
	public ModelAndView addShift(HttpServletRequest request, HttpServletResponse response, LeaveForm form)
			throws Exception {
		ModelAndView mv = new ModelAndView("/check/add_shift", Constants.FORM_COMMAND_KEY, form);
		mv.addObject("defaultSiteId", getDefaultSiteId());
		return mv;
	}

	@RequestMapping("/doAddShift")
	public ModelAndView doAddShift(HttpServletRequest request, HttpServletResponse response, LeaveForm form)
			throws Exception {
		ModelAndView mv = new ModelAndView("/check/check_add_result", Constants.FORM_COMMAND_KEY, form);
		// 添加
		Map<String, String> errMap = checkShiftService.insertShift(form);
		if (!CollectionUtils.isEmpty(errMap)) {
			mv.addObject("msg", errMap.get("errMsg"));
			return mv;
		}
		mv.addObject("status", "SUCCESS");
		return mv;
	}

	@RequestMapping("/shiftList")
	public ModelAndView shiftList(HttpServletRequest request, HttpServletResponse response, LeaveForm form)
			throws Exception {
		ModelAndView mv = new ModelAndView("/check/shift_list", Constants.FORM_COMMAND_KEY, form);
		String siteid = StringUtil.StringFilter(form.getSiteid());
		String deptid = StringUtil.StringFilter(form.getDeptid());
		if (siteid.equals("") || !isLegalSiteId(siteid)) {
			siteid = getDefaultSiteId();
		}
		form.setSiteid(siteid);
		form.setDeptid(deptid);
		int count = checkShiftService.selectShiftCount(siteid, deptid);
		if (count == 0)
			return mv;

		int pageNum = 1;
		if (StringUtils.isNotBlank(form.getPageNum())) {
			pageNum = Integer.valueOf(form.getPageNum());
		}
		PageModel pageModel = new PageModel(count, PageModel.DEFAULT_PAGE_SIZE, pageNum, form);
		int begin = pageModel.getBegin();
		int pageSize = pageModel.getPageSize();
		List<TblCheckShift> list = checkShiftService.selectShift(begin, pageSize, siteid, deptid);
		mv.addObject("list", list);
		return mv;
	}

	@RequestMapping("/deleteShift")
	@ResponseBody
	public Map<String, Object> deleteShift(HttpServletRequest request, HttpServletResponse response, LeaveForm form)
			throws Exception {
		String idStr = form.getId();
		String realId = "";
		if (StringUtils.isNotBlank(idStr)) {
			realId = EncrypTool.dencode(idStr);
		}
		int result = checkShiftService.deleteShift(realId + "");
		Map<String, Object> map = new HashMap<String, Object>();
		if (result > 0) {
			map.put("status", "FAILD");
		} else {
			map.put("status", "SUCCESS");
		}
		return map;
	}

	@RequestMapping("/editShift")
	public ModelAndView editShift(HttpServletRequest request, HttpServletResponse response, LeaveForm form)
			throws Exception {
		ModelAndView mv = new ModelAndView("/check/edit_shift", Constants.FORM_COMMAND_KEY, form);
		Long id = new Long(EncrypTool.dencode(form.getId()));
		TblCheckShift leave = checkShiftService.selectShiftById(id + "");
		mv.addObject("shift", leave);
		return mv;
	}

	@RequestMapping("/doEditShift")
	public ModelAndView doEditShift(HttpServletRequest request, HttpServletResponse response, LeaveForm form)
			throws Exception {
		ModelAndView mv = new ModelAndView("/check/check_add_result", Constants.FORM_COMMAND_KEY, form);
		String idStr = form.getId();
		String realId = "";
		if (StringUtils.isNotBlank(idStr)) {
			realId = EncrypTool.dencode(idStr);
		}
		TblCheckShift leave = checkShiftService.selectShiftById(realId);
		if (leave != null) {
			Map<String, String> errMap = checkShiftService.updateShift(form, realId);
			if (!CollectionUtils.isEmpty(errMap)) {
				mv.addObject("msg", errMap.get("errMsg"));
				return mv;
			}
		}
		mv.addObject("status", "SUCCESS");
		return mv;
	}

	@RequestMapping("/scheduleList")
	public ModelAndView scheduleList(HttpServletRequest request, HttpServletResponse response, LeaveForm form)
			throws Exception {
		ModelAndView mv = new ModelAndView("/check/schedule_list", Constants.FORM_COMMAND_KEY, form);
		String siteid = StringUtil.StringFilter(form.getSiteid());
		String userid = StringUtil.StringFilter(form.getUserid());
		String deptid = StringUtil.StringFilter(form.getDeptid());
		if (siteid.equals("") || !isLegalSiteId(siteid)) {
			siteid = getDefaultSiteId();
		}
		form.setSiteid(siteid);
		form.setUserid(userid);
		form.setDeptid(deptid);
		int count = checkShiftService.selectScheduleCount(siteid, userid, deptid);
		if (count == 0)
			return mv;

		int pageNum = 1;
		if (StringUtils.isNotBlank(form.getPageNum())) {
			pageNum = Integer.valueOf(form.getPageNum());
		}
		PageModel pageModel = new PageModel(count, PageModel.DEFAULT_PAGE_SIZE, pageNum, form);
		int begin = pageModel.getBegin();
		int pageSize = pageModel.getPageSize();
		List<TblCheckSchedule> list = checkShiftService.selectSchedule(begin, pageSize, siteid, userid, deptid);
		mv.addObject("list", list);
		return mv;
	}

	@RequestMapping("/addSchedule")
	public ModelAndView addSchedule(HttpServletRequest request, HttpServletResponse response, LeaveForm form)
			throws Exception {
		ModelAndView mv = new ModelAndView("/check/add_schedule", Constants.FORM_COMMAND_KEY, form);
		mv.addObject("defaultSiteId", getDefaultSiteId());
		return mv;
	}

	@RequestMapping("/doAddSchedule")
	public ModelAndView doAddSchedule(HttpServletRequest request, HttpServletResponse response, LeaveForm form)
			throws Exception {
		ModelAndView mv = new ModelAndView("/check/add_result", Constants.FORM_COMMAND_KEY, form);
		// 添加
		int result = checkShiftService.insertSchedule(form);
		if (result > 0) {
			mv.addObject("status", "SUCCESS");
		}
		return mv;
	}

	@RequestMapping("/deleteSchedule")
	@ResponseBody
	public Map<String, Object> deleteSchedule(HttpServletRequest request, HttpServletResponse response, LeaveForm form)
			throws Exception {
		String idStr = form.getId();
		String realId = "";
		if (StringUtils.isNotBlank(idStr)) {
			realId = EncrypTool.dencode(idStr);
		}
		int result = checkShiftService.deleteSchedule(realId + "");
		Map<String, Object> map = new HashMap<String, Object>();
		if (result > 0) {
			map.put("status", "FAILD");
		} else {
			map.put("status", "SUCCESS");
		}
		return map;
	}

	@RequestMapping("/editSchedule")
	public ModelAndView editSchedule(HttpServletRequest request, HttpServletResponse response, LeaveForm form)
			throws Exception {
		ModelAndView mv = new ModelAndView("/check/edit_schedule", Constants.FORM_COMMAND_KEY, form);
		Long id = new Long(EncrypTool.dencode(form.getId()));
		TblCheckSchedule schedule = checkShiftService.selectScheduleById(id + "");
		mv.addObject("schedule", schedule);
		return mv;
	}

	@RequestMapping("/doEditSchedule")
	public ModelAndView doEditSchedule(HttpServletRequest request, HttpServletResponse response, LeaveForm form)
			throws Exception {
		ModelAndView mv = new ModelAndView("/check/add_result", Constants.FORM_COMMAND_KEY, form);
		String idStr = form.getId();
		String realId = "";
		if (StringUtils.isNotBlank(idStr)) {
			realId = EncrypTool.dencode(idStr);
		}
		TblCheckSchedule schedule = checkShiftService.selectScheduleById(realId);
		if (schedule != null) {
			int count = checkShiftService.updateSchedule(form, realId);
			if (count > 0) {
				mv.addObject("status", "SUCCESS");
			}
		}
		return mv;
	}

	/**
	 * 个人排班明细
	 * 
	 * @param request
	 * @param response
	 * @param form
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("/userSchedule")
	public ModelAndView userSchedule(HttpServletRequest request, HttpServletResponse response, LeaveForm form)
			throws Exception {
		ModelAndView mv = new ModelAndView("/check/user_schedule", Constants.FORM_COMMAND_KEY, form);
		String userid = form.getUserid();
		String username = form.getUsername();
		String scheduleid = form.getScheduleid();
		Map<String, String> map = checkShiftService.selectUserSchedule(userid, scheduleid);
		map.put("username", username);
		mv.addObject("schedule", null);
		mv.addObject("map", map);
		return mv;
	}

	@RequestMapping("/userList")
	public ModelAndView userList(HttpServletRequest request, HttpServletResponse response, LeaveForm form)
			throws Exception {
		ModelAndView mv = new ModelAndView("/check/user_list", Constants.FORM_COMMAND_KEY, form);
		String siteid = StringUtil.StringFilter(form.getSiteid());
		if (!isLegalSiteId(siteid)) {
			return null;
		}
		String userid = StringUtil.StringFilter(form.getUserid());
		String deptid = StringUtil.StringFilter(form.getDeptid());
		String username = StringUtil.StringFilter(form.getUsername());
		form.setSiteid(siteid);
		form.setUserid(userid);
		form.setDeptid(deptid);
		form.setUsername(username);
		int count = checkShiftService.selectUserCount(siteid, deptid, userid, username);
		if (count == 0)
			return mv;

		int pageNum = 1;
		if (StringUtils.isNotBlank(form.getPageNum())) {
			pageNum = Integer.valueOf(form.getPageNum());
		}
		PageModel pageModel = new PageModel(count, PageModel.DEFAULT_PAGE_SIZE, pageNum, form);
		int begin = pageModel.getBegin();
		int pageSize = pageModel.getPageSize();
		List<TsUser> list = checkShiftService.selectUser(begin, pageSize, siteid, deptid, userid, username);
		mv.addObject("list", list);
		// 获取默认站点
		mv.addObject("defaultSiteId", getDefaultSiteId());
		return mv;
	}

	@RequestMapping(value = "/editUser")
	public ModelAndView editUser(HttpServletRequest request, HttpServletResponse response, LeaveForm form)
			throws Exception {
		String userId = form.getId();
		String realId = "";
		if (StringUtils.isNotBlank(userId)) {
			realId = EncrypTool.dencode(userId);
		}
		String siteid = form.getSiteid().trim();

		ModelAndView mv = new ModelAndView("/check/edit_user", Constants.FORM_COMMAND_KEY, form);
		TsUser user = settingService.selectUserWithRoleByUserId(realId);
		List<TblOaAuthRole> roleList = settingService.selectRoleList4Check(siteid);
		mv.addObject("roleList", roleList);
		mv.addObject("user", user);
		return mv;
	}

	@RequestMapping(value = "/doEditUser")
	public ModelAndView doEditUser(HttpServletRequest request, HttpServletResponse response, LeaveForm form)
			throws Exception {
		ModelAndView mv = new ModelAndView("/check/user_edit_result", Constants.FORM_COMMAND_KEY, form);
		if (StringUtils.isNotBlank(form.getUserid()) && StringUtils.isNotBlank(form.getRoles())) {
			// 1.检测重复
			TsUser existUser = settingService.selectByUserId(form.getUserid().trim());
			if (null != existUser) {
				settingService.updateUser4Check(form);
				mv.addObject("status", "SUCCESS");
				return mv;
			}
			mv.addObject("msg", "该用户不存在");
			mv.addObject("status", "FAILD");
			return mv;
		}

		mv.addObject("msg", "提交数据有误，请不要留空值，请勿改动页面");
		mv.addObject("status", "FAILD");
		return mv;
	}

	@RequestMapping("/roleList")
	public ModelAndView roleList(HttpServletRequest request, HttpServletResponse response, LeaveForm form)
			throws Exception {
		ModelAndView mv = new ModelAndView("/check/role_list", Constants.FORM_COMMAND_KEY, form);
		String siteid = StringUtil.StringFilter(form.getSiteid());
		String rolename = StringUtil.StringFilter(form.getRolename());
		form.setSiteid(siteid);
		form.setRolename(rolename);
		int count = checkShiftService.selectTblOaAuthRoleCount(siteid, rolename);
		if (count == 0)
			return mv;

		int pageNum = 1;
		if (StringUtils.isNotBlank(form.getPageNum())) {
			pageNum = Integer.valueOf(form.getPageNum());
		}
		PageModel pageModel = new PageModel(count, PageModel.DEFAULT_PAGE_SIZE, pageNum, form);
		int begin = pageModel.getBegin();
		int pageSize = pageModel.getPageSize();
		List<TblOaAuthRole> list = checkShiftService.selectTblOaAuthRole(begin, pageSize, siteid, rolename);
		mv.addObject("list", list);
		mv.addObject("defaultSiteId", getDefaultSiteId());
		return mv;
	}

	@RequestMapping(value = "/addRole")
	public ModelAndView addRole(HttpServletRequest request, HttpServletResponse response, LeaveForm form)
			throws Exception {
		ModelAndView mv = new ModelAndView("/check/add_role", Constants.FORM_COMMAND_KEY, form);
		List<TblOaAuthPermission> permissionlist = settingService.selectAllPremission4Check();
		mv.addObject("rolepermissionlistList", permissionlist);
		return mv;
	}

	@RequestMapping(value = "/doAddRole")
	public ModelAndView doAddRole(HttpServletRequest request, HttpServletResponse response, LeaveForm form)
			throws Exception {
		ModelAndView mv = new ModelAndView("/check/role_add_result", Constants.FORM_COMMAND_KEY, form);
		if (StringUtils.isNotBlank(form.getRolename()) && StringUtils.isNotBlank(form.getPermissioins())
				&& StringUtils.isNotBlank(form.getSiteid())) {
			// 1.检测重复
			TblOaAuthRole existRole = settingService.selectRoleByDescAndSiteId(form.getRolename(), form.getSiteid()
					.trim());
			if (null == existRole) {
				if (form.getRolename().contains(",")) {
					mv.addObject("msg", "角色名称包含非法字符");
					mv.addObject("status", "FAILD");
					return mv;
				}
				settingService.insertRole4Check(form);
				mv.addObject("status", "SUCCESS");
				return mv;
			}
			mv.addObject("msg", "该角色名称已存在,请勿重复添加");
			mv.addObject("status", "FAILD");
			return mv;
		}

		mv.addObject("msg", "请填写字段完整");
		mv.addObject("status", "FAILD");
		return mv;
	}

	@RequestMapping(value = "/editRole")
	public ModelAndView editRole(HttpServletRequest request, HttpServletResponse response, LeaveForm form)
			throws Exception {
		String roleId = form.getId();
		if (StringUtils.isNotBlank(roleId)) {
			roleId = EncrypTool.dencode(roleId);
		} else {
			return null;
		}
		ModelAndView mv = new ModelAndView("/check/edit_role", Constants.FORM_COMMAND_KEY, form);
		TblOaAuthRole role = settingService.selectRoleByRoleId(roleId);
		List<TblOaAuthPermission> permissionlist = settingService.selectAllPremission4Check();
		mv.addObject("permissionlist", permissionlist);
		mv.addObject("role", role);
		return mv;
	}

	@RequestMapping(value = "/doEditRole")
	public ModelAndView doEditRole(HttpServletRequest request, HttpServletResponse response, LeaveForm form)
			throws Exception {
		ModelAndView mv = new ModelAndView("/check/role_add_result", Constants.FORM_COMMAND_KEY, form);
		if (StringUtils.isNotBlank(form.getRoleId()) && StringUtils.isNotBlank(form.getRolename())
				&& StringUtils.isNotBlank(form.getPermissioins()) && StringUtils.isNotBlank(form.getSiteid())) {
			String realRoleId = EncrypTool.dencode(form.getRoleId());
			// 1.检测重复
			TblOaAuthRole existRole = settingService.selectRoleByDescAndSiteId(form.getRolename(), form.getSiteid()
					.trim());
			if (null == existRole) {
				settingService.updateRole4Check(realRoleId, form.getRolename(), form.getPermissioins(), form
						.getSiteid().trim());
				mv.addObject("status", "SUCCESS");
				return mv;
			}
			mv.addObject("msg", "该角色名称已存在,请勿重复添加");
			mv.addObject("status", "FAILD");
			return mv;
		}

		mv.addObject("msg", "提交数据有误，请不要留空值，请勿改动页面");
		mv.addObject("status", "FAILD");
		return mv;
	}

	@RequestMapping(value = "/doDeleteRole")
	public ModelAndView doDeleteRole(HttpServletRequest request, HttpServletResponse response, LeaveForm form)
			throws Exception {
		String roleId = form.getId();
		if (StringUtils.isNotBlank(roleId)) {
			roleId = EncrypTool.dencode(roleId);
		}
		int result = settingService.deleteRoleByRoleId(roleId);
		Map map = new HashMap<String, String>();
		if (result == -1) {
			map.put("status", "FAILD");
		} else if (result == 0) {
			map.put("status", "SUCCESS");
		}
		ModelAndView mv = new ModelAndView(new XFMappingJacksonJsonView(), map);
		return mv;
	}

	@RequestMapping(value = "/allHour")
	public void allHour(HttpServletRequest request, HttpServletResponse response, LeaveForm form) throws Exception {
		String[] hourIds = new String[] { "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12",
				"13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" };
		List<Map> list = new ArrayList<Map>();
		for (String s : hourIds) {
			Map<String, String> map = new HashMap<String, String>();
			map.put("hourId", s);
			map.put("hourName", s);
			list.add(map);
		}
		String jsonString = JSONArray.toJSONString(list);
		response.getWriter().write(jsonString);
	}

	@RequestMapping(value = "/allMinute")
	public void allMinute(HttpServletRequest request, HttpServletResponse response, LeaveForm form) throws Exception {
		String[] hourIds = new String[] { "00", "05", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55" };
		List<Map> list = new ArrayList<Map>();
		for (String s : hourIds) {
			Map<String, String> map = new HashMap<String, String>();
			map.put("minuteId", s);
			map.put("minuteName", s);
			list.add(map);
		}
		String jsonString = JSONArray.toJSONString(list);
		response.getWriter().write(jsonString);
	}

	@RequestMapping(value = "/laterMinute")
	public void laterMinute(HttpServletRequest request, HttpServletResponse response, LeaveForm form) throws Exception {
		String[] minutes = new String[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" };
		List<Map> list = new ArrayList<Map>();
		for (String s : minutes) {
			Map<String, String> map = new HashMap<String, String>();
			map.put("minuteId", s);
			map.put("minuteName", s);
			list.add(map);
		}
		String jsonString = JSONArray.toJSONString(list);
		response.getWriter().write(jsonString);
	}

	@RequestMapping(value = "/elareyMinute")
	public void earlyMinute(HttpServletRequest request, HttpServletResponse response, LeaveForm form) throws Exception {
		String[] minutes = new String[] { "10", "20", "30", "40", "50", "60", "70", "80", "90", "120", "180" };
		List<Map> list = new ArrayList<Map>();
		for (String s : minutes) {
			Map<String, String> map = new HashMap<String, String>();
			map.put("minuteId", s);
			map.put("minuteName", s);
			list.add(map);
		}
		String jsonString = JSONArray.toJSONString(list);
		response.getWriter().write(jsonString);
	}

	@RequestMapping(value = "/checkedDays")
	public void checkedDays(HttpServletRequest request, HttpServletResponse response, LeaveForm form) throws Exception {
		String[] minutes = new String[] { "0.25", "0.5", "1" };
		List<Map> list = new ArrayList<Map>();
		for (String s : minutes) {
			Map<String, String> map = new HashMap<String, String>();
			map.put("dayId", s);
			map.put("dayName", s);
			list.add(map);
		}
		String jsonString = JSONArray.toJSONString(list);
		response.getWriter().write(jsonString);
	}

	@RequestMapping("/shiftListBySiteId")
	@ResponseBody
	public List<TblCheckShift> shiftListBySiteId(HttpServletRequest request, HttpServletResponse response,
			LeaveForm form) {
		String siteId = form.getSiteid().trim();
		return checkShiftService.selectShiftBySiteId(siteId);
	}

	/**
	 * 获取用户默认选择的站点
	 * 
	 * @return
	 */
	private String getDefaultSiteId() {
		UserInfo user = (UserInfo) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
		ArrayList<String> remainList = new ArrayList<String>();
		if (!"769000".equalsIgnoreCase(user.getSiteId())) {
			remainList.add(user.getSiteId());
		}
		Object auths[] = SecurityContextHolder.getContext().getAuthentication().getAuthorities().toArray();
		for (Object o : auths) {
			String auth = o + "";
			if (auth.equals("MANAGE_CHECK_HUMEN") || auth.equals("MANAGE_CHECK_SHENZHEN"))
				continue;
			if (auth.contains("MANAGE_CHECK_")) {
				String siteId = auth.substring(13, 19);
				if (!remainList.contains(siteId)) {
					remainList.add(siteId);
				}
			}
		}
		if (!CollectionUtils.isEmpty(remainList)) {
			return remainList.get(0);
		}
		return null;
	}

	private boolean isLegalSiteId(String siteId) {
		if (StringUtils.isBlank(siteId))
			return false;
		UserInfo user = (UserInfo) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
		ArrayList<String> remainList = new ArrayList<String>();
		if (!"769000".equalsIgnoreCase(user.getSiteId())) {
			remainList.add(user.getSiteId());
		}
		Object auths[] = SecurityContextHolder.getContext().getAuthentication().getAuthorities().toArray();
		for (Object o : auths) {
			String auth = o + "";
			if (auth.equals("MANAGE_CHECK_HUMEN") || auth.equals("MANAGE_CHECK_SHENZHEN"))
				continue;
			if (auth.contains("MANAGE_CHECK_")) {
				String s = auth.substring(13, 19);
				if (!remainList.contains(s)) {
					remainList.add(s);
				}
			}
		}
		if (!CollectionUtils.isEmpty(remainList)) {
			if (remainList.contains(siteId)) {
				return true;
			}
		}
		return false;
	}
}
